package com.ys.servers.common.dao;

import com.ys.servers.common.data.DataEntity;
import com.ys.servers.common.data.DataReader;
import io.vertx.core.Future;

/**
 * Created by taotao on 2017/3/7.
 */
public class BasicNoSqlDao<T extends DataEntity> {

    //private JDBCWrapper jdbcWrapper;

    protected DataReader dataReader;

    public BasicNoSqlDao() {
        dataReader = DataReader.getInstance();
    }

    public <T extends DataEntity> Future<T> addData(T obj) {
        return dataReader.save(obj);
    }

    public Future<Boolean> deleteData(String id, Class<T> clazz) {
        return dataReader.remove(id, clazz);
    }

    public Future<Boolean> deprecateData(String id, Class<T> clazz) {
        return dataReader.deprecate(id, clazz);
    }

    public Future<T> restore(String id, Class<T> clazz) {
        return dataReader.restore(id, clazz);
    }

    public <T extends DataEntity> Future<T> getData(String id, Class<T> clazz) {
        return dataReader.get(id, clazz);
    }

    public DataReader getDataReader() {
        return dataReader;
    }

    public BasicNoSqlDao setDataReader(DataReader dataReader) {
        this.dataReader = dataReader;
        return this;
    }

    /* public BasicNoSqlDao(Vertx vertx, JsonObject config) {
        jdbcWrapper = new JDBCHikariWrapper(vertx, config);
    }

    public JDBCWrapper getJdbcWrapper() {
        return jdbcWrapper;
    }

    public BasicNoSqlDao setJdbcWrapper(JDBCWrapper jdbcWrapper) {
        this.jdbcWrapper = jdbcWrapper;
        return this;
    }*/
}
